package studyguide.ch09.simple;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

public class SimpleCanvas extends Canvas {

	protected void paint(Graphics g) {
		g.setColor(0, 0, 0); // Black
		
		int screenWidth = getWidth();
		int screenHeight = getHeight();
		
		// Fill a rectangle on the center of the screen
		g.fillRect(
				screenWidth / 3, screenHeight / 3,  // X0, Y0 
				screenWidth / 3, screenHeight / 3); // width, height
		
		// Write a message:
		g.drawString(
				"SimpleCanvas. Screen should have been cleared!", 
				screenWidth/2, 
				3*screenHeight/4, 
				Graphics.TOP | Graphics.HCENTER);
	}

}
